import { loadNewsByIdAPI } from '../../api/news';
import { NEWS_SET_LIST } from 'actionType';

// 2 定义异步Action，请求文章列表
export const getNewsById = (id) => {
  return async (dispatch) => {
    const { data } = await loadNewsByIdAPI(id);
    console.log('results  ----->  ', data.results);
    // 5. dispatch保存数据
    dispatch({
      type: NEWS_SET_LIST,
      payload: data.results,
    });
  };
};
